from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from routers.card.router import card_router
from routers.book.router import book_router
from routers.borrow_info.router import borrow_info_router
from routers.fine.router import fine_router

app = FastAPI()
# 设置跨域允许
origins = [
    "http://localhost:8080",
    "https://dp.632891553.xyz"
]
#跨域允许中间件
app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
#引入接口
app.include_router(router=card_router)
app.include_router(router=book_router)
app.include_router(router=borrow_info_router)
app.include_router(router=fine_router)

@app.get("/",summary='Test接口',tags=["测试接口"])
def read_root():
    return {"Hello": "World"}


